/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
// try {
//     var HID = require('node-hid')
// } catch (e) {
//     console.log(e)
// }




// Colour_category : { colour: '3e86ea'
// List_category : { colour: '123'
// Logic_category : { colour: '3e86ea'
// Loops_category : { colour: '3e86ea'
// Math_category : { colour: '3e86ea'
// Text_category : { colour: '3e86ea'
// Variables_category : { colour: '3e86ea'
// VariablesDynamic_category : { colour: '3e86ea'
// Colour_category.Hue
// Colour_category.Hue

// globalThis.SerialPort = SerialPort

Blockly.WorkspaceSvg.prototype.translate = function(x, y) {
    if (this.useWorkspaceDragSurface_ && this.isDragSurfaceActive_) {
        this.workspaceDragSurface_.translateSurface(x, y);
    } else {
        var translation = 'translate(' + x + ',' + y + ') ' +
            'scale(' + this.scale + ')';
        this.svgBlockCanvas_.setAttribute('transform', translation);
        this.svgBubbleCanvas_.setAttribute('transform', translation);
    }
    // Now update the block drag surface if we're using one.
    if (this.blockDragSurface_) {
        this.blockDragSurface_.translateAndScaleGroup(x, y, this.scale);
    }
    // And update the grid if we're using one.
    if (this.grid_) {
        this.grid_.moveTo(x, y);
    }
};

Blockly.VerticalFlyout.prototype.setMetrics_ = function(xyRatio) {
    var metrics = this.getMetrics_();

    // This is a fix to an apparent race condition.
    if (!metrics) {
        return;
    }
    let num = 0
    if (metrics.viewTop - this.workspace_.scrollY > 10) {
        num = -300
    }
    if (typeof xyRatio.y == 'number') {
        this.workspace_.scrollY = -metrics.contentHeight * xyRatio.y;
    }
    this.workspace_.translate(this.workspace_.scrollX + metrics.absoluteLeft,
        this.workspace_.scrollY + metrics.absoluteTop + num);
};